<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>解构赋值</title>
</head>
<body>

</body>
<script>

  let arr1 = [1,23,5];
  let  arr2=[45,6];

  let arr3=[];

  /**
   * 1. 循环
   * */

  // for (let i = 0; i < arr2.length; i++) {
  //      arr1.push(arr2[i]); //  push是一个变异操作 arr1被改变
  // }
  // arr3 = arr1;


  /**
   * 2.函数
   * */

 arr3= arr1.concat(arr2);// 非变异操作

 /*console.log(arr1);
  console.log(arr2);
  console.log(arr3);*/

/**
 *  3. es6 解构赋值
 *    数组和对象的解构赋值
 * */
   arr3=[...arr1,...arr2];

   let emp1={
     id:1,
     age:23
   };

   let emp2={
      gender:'male',
      dept:'HR'
   }

   let emp = {
      ...emp1,
      ...emp2
   }

   console.log(emp);


</script>
</html>